<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    // 序列化和反序列化
    // 1.序列化-对象转为json对象-JSON.stringify(对象名)
    let student = {
        name: "张三",
        age: 18,
        sex: '男'
    }
    jsonStudent = JSON.stringify(student)
    console.log(jsonStudent)
    // 2.反序列化-json对象转为对象-JSON.parse(json对象)
    console.log(JSON.parse(jsonStudent))
</script>
</html>